﻿@using Smartstore.Web.Models.Catalog

@model IList<TierPriceModel>

@{
    var displayTierPrices = false;
    if (Model.Count > 0 && !(Model.Count == 1 && Model[0].Quantity <= 1))
    {
        // When there is just one tier (with  qty 1), there are no actual savings in the list.
        displayTierPrices = true;
    }

    if (!displayTierPrices)
    {
        return;
    }
}

<div class="pd-tierprices pd-group" role="region" aria-labelledby="pd-tierprices-title">
    <h6 id="pd-tierprices-title" class="font-weight-medium mb-2">
        @Html.Raw(T("Products.TierPrices"))
    </h6>
    <div class="table-responsive">
        <table class="table table-bordered table-sm table-tierprices@(Model.Count > 5 ? " d-block" : "")">
            <caption class="sr-only">@Html.Raw(T("Products.TierPrices"))</caption>
            <thead>
                <tr>
                    <th scope="col">@T("Products.TierPrices.Quantity")</th>
                    @foreach (var tierPrice in Model.Take(200))
                    {
                        <th id="pd-tierprice-qty-@tierPrice.Quantity" scope="col" class="pd-tierprice-qty text-center">
                            <data value="@tierPrice.Quantity">@(tierPrice.Quantity)+</data>
                        </th>
                    }
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>@T("Products.TierPrices.Price")</td>
                    @foreach (var tierPrice in Model.Take(200))
                    {
                        <td headers="pd-tierprice-qty-@tierPrice.Quantity" class="pd-tierprice-price text-nowrap text-center">
                            <data asp-for="@tierPrice.Price">@tierPrice.Price</data>
                        </td>
                    }
                </tr>
            </tbody>
        </table>
    </div>
</div>